package Java攻略._2_java_util_function包._2_Supplier接口;

import java.util.function.DoubleSupplier;

public class _4_使用Math_random作为Supplier {


    public static void main(String[] args) {

        // 匿名内部类实现
        DoubleSupplier doubleSupplier = new DoubleSupplier() {
            @Override
            public double getAsDouble() {
                return Math.random();
            }
        };

        // lambda表达式
        doubleSupplier = () -> Math.random();

        // 方法引用
        doubleSupplier = Math::random;

        double asDouble = doubleSupplier.getAsDouble();
        System.out.println(asDouble);

    }
}
